//
//  Person.m
//  OC02_方法
//
//  Created by dllo on 15/12/1.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "Person.h"

@implementation Person

/* 初始化方法 */
- (instancetype)initWithName:(NSString *)name{
    self = [super init]; /* self关键字: 指当前类的对象 */
    if (self) {
        _name = name;
        
    }
    return self;
}
- (instancetype)initWithName:(NSString *)name
                         age:(NSInteger)age
                         sex:(NSString *)sex{
    
    self = [super init]; /* self关键字: 指当前类的对象 */
    if (self) {
        _name = name;
        _age = age;
        _sex = sex;

        
        
    }
    return self;
    
}




+ (instancetype)personWithName:(NSString *)name
                           age:(NSInteger)age
                           sex:(NSString *)sex{
    Person *per = [[Person alloc] initWithName:name age:age sex:sex];
    
    return per;
    
}
+ (instancetype)person;{
    
    Person *per = [[Person alloc] init];
    return per;
}



/** getter方法 目的 取出一个实例变量的值*/
- (NSString *)name{
    
    
    return _name;
    
}
- (NSInteger)age{
    
    return _age;

}

- (NSString *)sex{
    
    return _sex;
    
}


/** setter方法 目的  给一个实例变量赋值 */

- (void)setName:(NSString *)name{
    
    _name = name;
    
}

- (void)setAge:(NSInteger)age{
    
    _age = age;
}

- (void)setSex:(NSString *)sex{
    
    _sex = sex;
}




- (void)info{
    
    
    NSLog(@"name:%@, age:%ld, sex:%@", _name, _age, _sex);
    
    
}

- (void)study{
    
    
    NSLog(@"我要学习");
    
}








@end
